package org.Big;
// JDK 17

import java.math.BigInteger;

public class TestBigInteger {
    //    BigInteger;
    public static void test() {
        BigInteger bi = new BigInteger("1234567890");
        System.out.println(bi.pow(5)); // 2867971860299718107233761438093672048294900000

        // BigInteger to long
        BigInteger i = new BigInteger("123456789000");
        System.out.println(i.longValue()); // 123456789000
        try {
//            System.out.println(i.multiply(i).longValue());
            System.out.println(i.multiply(i).longValueExact()); // java.lang.ArithmeticException: BigInteger out of long range
        } catch (ArithmeticException exception) {
            System.out.println(exception.toString());
        }

    }
}
